package cn.data.collection.util;

import java.io.FileInputStream;
import java.util.Properties;

import cn.data.collection.constant.InitPropertiesConstant;

public class PropertiesUtils {
	private Properties INITDATA = new Properties();
	private static final String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();

	// 私有的默认构造子
	private PropertiesUtils() {
	}

	// 注意，这里没有final
	private static PropertiesUtils single = null;

	// 静态工厂方法
	public static PropertiesUtils getInstance() throws Exception {
		if (single == null) {
			single = new PropertiesUtils();
			try {
				single.init();
			} catch (Exception e) {
				LoggerUtils.getInstance().error(e);
				throw e;
			}
		}
		return single;
	}

	public Properties getINITDATA() {
		return INITDATA;
	}

	private void init() throws Exception {
		INITDATA.load(new FileInputStream(path + "/" + "init.properties"));
	}

	public static void main(String[] args) throws Exception {
		PropertiesUtils objPropertiesUtils = PropertiesUtils.getInstance();
		String str = objPropertiesUtils.INITDATA.get(InitPropertiesConstant.COLLECTION_DATE).toString();
		str.split(",");
		System.out.println( str);
	}
}
